﻿Public Class DonGiaThue
    Public Shared Function DanhSach() As DataTable
        Return db.QueryTable("select BienSo,g.MaHT,TenHT, DonGia from GiaThue g inner join HinhThucThue h on h.MaHT = g.MaHT")
    End Function
    Public Shared Function DanhSachHT() As DataTable
        Return db.QueryTable("Select * from HinhThucThue")
    End Function
    Public Shared Function ThemDG(ByVal BienSo As String, ByVal MaHT As String, ByVal DonGia As String) As Boolean
        BienSo = EscapeString(BienSo)
        MaHT = EscapeString(MaHT)
        Return db.Query("INSERT INTO GiaThue(BienSo,MaHT,DonGia) VALUES ('" & BienSo & "','" & MaHT & "'," & DonGia & ")")
    End Function
    Public Shared Function timkiem(ByVal tukhoa As String) As DataTable
        tukhoa = EscapeString(tukhoa)
        'Return db.QueryTable("SELECT g.BienSo,h.TenHT,g.DonGia FROM GiaThue g,HinhThucThue h WHERE( BienSo like '%" & tukhoa & "%' or h.TenHT like N'%" & tukhoa & "%' or DonGia like '%" & tukhoa & "%'and h.MaHT= g.MaHT)")
        Return db.QueryTable("SELECT BienSo,MaHT,DonGia FROM GiaThue WHERE( BienSo like '%" & tukhoa & "%' or MaHT like '%" & tukhoa & "%' or DonGia like '%" & tukhoa & "%')")
    End Function
    Public Shared Function capnhat(ByVal bienso As String, ByVal maht As String, ByVal dongia As String) As Boolean
        bienso = EscapeString(bienso)
        maht = EscapeString(maht)
        dongia = EscapeString(dongia)
        Return db.Query("UPDATE GiaThue SET DonGia= '" + dongia + "',MaHT = '" + maht + "'WHERE BienSo = '" + bienso + "'")
    End Function
    Public Shared Function xoa(ByVal bienso As String) As Boolean
        bienso = EscapeString(bienso)
        Return db.Query("DELETE FROM GiaThue WHERE BienSo= '" + bienso + "'")
    End Function

End Class
